/* Javascript: se define un objeto con callbacks globales */
var globalCallbacks = {
  onCreate: function(){
    if ($('flash_error')) {
      $('flash_error').hide();
    }
    if ($('flash_success')) {
      $('flash_success').hide();
    }
    $('loading').show();
  },
  onComplete: function() {
    if(Ajax.activeRequestCount == 0){
      $('loading').hide();
    }
  },
  onFailure: function() {
    $('failure_error').show();
  },
  onException: function() {
    $('exception_error').show();
  }
};
/* Se registran los callbacks en Ajax.Responders */
/* Ajax.Responders.register( globalCallbacks );  */

function changeTab(i) {
  tabSelect($('tab' + i)); 
  paneSelect($('pane' + i)); 
}

function tabSelect(tab) {
  var tablist = $('tab_control').getElementsByTagName('li');
  var nodes = $A(tablist);

  nodes.each(function(node){
    if (node.id == tab.id) {
      tab.className='tab-selected';
	} else {
      node.className='tab-unselected';
	};
  });
}

function paneSelect(pane) {
  var panelist = $('pane_control').getElementsByTagName('li');
  var nodes = $A(panelist);

  nodes.each(function(node){
    if (node.id == pane.id) {
      pane.className='pane-selected';
	} else {
      node.className='pane-unselected';
	};
  });
}

function hide_element(element) {
  element.style.display = 'none';
}
